package com.example.mapper;

import com.example.entity.Supplier;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SupplierMapper {

    /**
     * 查询所有供应商
     */
    @Select("select * from mall_backend.supplier")
    List<Supplier> list();

    /**
     * 删除供应商
     */
    @Delete("delete * from supplier where id = #{id}")
    void delete(Integer id);

    /**
     * 新增供应商
     */
    @Insert("insert into mall_backend.supplier(name, phone, address, create_time, update_time) " +
            "values (#{name}, #{phone}, #{address}, #{createTime}, #{updateTime})")
    void insert(Supplier supplier);

    /**
     * 根据id查询供应商
     */
    @Select("select * from mall_backend.supplier where id = #{id}")
    Supplier getById(Integer id);

    /**
     * 更新供应商信息
     */
    void update(Supplier supplier);
}
